<template>
  <div class='wrap'>
    <div class='container w'>
      <el-card>
        <div slot="header" class="header">
          <div><i class="iconfont icon-huo"></i>热门文章</div>
          <div @click="huanyihuan(query.pageNum)" style="cursor:pointer"><i class="iconfont icon-huanyihuan"></i>换一换</div>
          </div>
        <div class="item" v-for="(item,index) in hotArticle" :key="index" @click="$router.push({name: 'NewsDetails', params: { article_id:`${item.id}`}})">
          <span>{{item.title}}</span>
        </div>
      </el-card>
    </div>
   </div>
</template>

<script>
import {getHotArticle} from '@/api/news/pc-web/article'
  export default {
    name: 'HotArticle',
    components: {},
    data() {
      return {
        hotArticle:[],
        query:{
          pageNum:1,
          pageSize:6
        }
      };
    },
    created() {
      this.getHotArticle()
    },
    methods: {
      async getHotArticle(){
        const { list, pageNum, pageSize} = await getHotArticle(this.query)
        this.query.pageNum = pageNum;
        this.query.pageSize = pageSize;
        this.hotArticle = list;
      },
      huanyihuan(val){
        this.query.pageNum = ++this.query.pageNum;
        this.getHotArticle()
      },
    }, 
  };
</script>
<style lang="scss" scoped>
.el-card  {
  box-shadow: 0 2px 8px 0px rgba(122 192 241 / 30%);
  // box-shadow: none;
}
::v-deep .el-card__header{
  padding: 10px 20px;
}
::v-deep .el-card__body{
  padding: 10px 20px
}
.header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  .iconfont{
    color: rgb(234, 25, 25);
    margin-right: 3px;
  }
  .icon-huo{
    font-size: 18px;
  }
}
.item{
  span:hover{
    color: #6292f0;
  cursor: pointer;
  }
  color: #606266;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 2.4;
  text-overflow: ellipsis;
  overflow: hidden; //隐藏文字
}

</style>